package com.relife.core.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

@Entity
@Table(name = "sys_area")
public class AreaEntity implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Integer id;
    /** 名称 **/
    private String name;
    /** 区位码 **/
    private Integer idCode;
    //** 1:省，2：市，3：县 **/
    private Integer arealevel;
    /** 全称 **/
    private String fullname;
    /** 上级id **/
    private AreaEntity parent;
    
	private List<AreaEntity> children;
	public AreaEntity() {
	}
	
	public AreaEntity(Integer id) {
		this.setId(id);
	}
	
	public AreaEntity(Integer id,String name) {
		this.setId(id);
		this.setName(name);
	}
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
	@OrderBy(value = "idCode ASC")
	public List<AreaEntity> getChildren() {
		return children;
	}

	public void setChildren(List<AreaEntity> children) {
		this.children = children;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id")
	public AreaEntity getParent() {
		return parent;
	}

	public void setParent(AreaEntity parent) {
		this.parent = parent;
	}

	 /** 区位码 **/
    
		@Column(name="ID_CODE")
	    public Integer getIdCode() {
			return idCode;
		}

	    /** 区位码 **/
		public void setIdCode(Integer idCode) {
			this.idCode = idCode;
		}
	    /** 区域级别 **/
	    
		@Column(name="AREALEVEL")
	    public Integer getArealevel() {
			return arealevel;
		}

	    /** 区域级别 **/
		public void setArealevel(Integer arealevel) {
			this.arealevel = arealevel;
		}
	    /** 全称 **/
	    
		@Column(name="FULLNAME")
	    public String getFullname() {
			return fullname;
		}

	    /** 全称 **/
		public void setFullname(String fullname) {
			this.fullname = fullname;
		}

}
